import json
import time

from dataProcess import Read_data

with open("../file_location.json", 'r', encoding="utf-8") as load_file:
    CONFIG = json.load(load_file)
data_location = CONFIG["location"]["data_root"]
data_after_process = Read_data.process_data()
data_data_relate = data_location + CONFIG["location"]["data_relate"]
data_after_statistic = data_location + CONFIG["location"]["data_statistic"]
data_mid_word = data_location + CONFIG["location"]["data_midWord"]
data_apart_root = data_location + CONFIG["location"]["data_apart"]
data_statistic_root = data_location + CONFIG["location"]["data_statistic"]
data_temp = data_location + CONFIG["location"]["data_temp"]
seed_word = "中国"
data_relate = data_location + CONFIG["location"]["data_relate"] + "compare/" + seed_word + "_in_method.txt"


def in_method():
    # 创建写入文件，将与种子关键字相关的内容写入文件中
    f_relate = open(data_relate, 'a', encoding='utf-8')

    for line in data_after_process:
        value_line = line
        # 判断是否包含种子关键字

        value_line.replace("\t", "")
        value_line.replace("\n", "")
        # 逐条匹配，如果找到了字符串则为成功
        if seed_word in value_line:
            is_contain = True
            f_relate.write(value_line)
            f_relate.write("\n")


if __name__ == "main":
    timeStart = time.time()

    in_method()

    timeEnd = time.time()
    print(timeEnd - timeStart)
